home *** CD-ROM | disk | FTP | other *** search
Lisp/Scheme | 1988-04-07 | 2.0 KB | 68 lines | [TEXT/ttxt] |
- ;; Larry Mulcahy 1988
- ;; sequence functions
-
- (provide 'sequence)
- (require 'array)
- (require 'string-primitive "str-prim")
- (require 's-expression-primitive "sexprim")
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; concatenate
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun concatenate (type &rest args)
- (case type
- (string (apply #'strcat args))
- (array (apply #'concatenate-vectors args))
- (cons (apply #'append args))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; elt
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun elt (s i)
- (case (type-of s)
- (cons (nth i s))
- (string (char s i))
- (array (aref s i))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; position
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun position (e s)
- (case (type-of s)
- (cons (list:position e s))
- (string (string:position e s))
- (array (vector:position e s))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; position-if
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun position-if (test s)
- (case (type-of s)
- (cons (list:position-if test s))
- (string (string:position-if test s))
- (array (vector:position-if test s))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; position-if-not
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun position-if-not (test s)
- (case (type-of s)
- (cons (list:position-if-not test s))
- (string (string:position-if-not test s))
- (array (vector:position-if-not test s))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; substitute
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun substitute (new old s &key (test #'eql))
- (case (type-of s)
- (string (string:substitute new old s :test test))
- (cons (subst new old s :test test))
- ))
-